﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;

public partial class ChangePassword : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
	protected void Button1_Click(object sender, EventArgs e)
	{
		this.Validate();
		if (!this.IsValid)
			return;
		int teacherId = int.Parse(Thread.CurrentPrincipal.Identity.Name);

		DataLayer dal = new DataLayer();
		string message = string.Empty;
		dal.ChangePassword(PAConfiguration.ConnectionString, teacherId, uname.Value, out message);

		if (message != string.Empty)
		{
			PALogManager.ErrorLog(message);
			ErrorMessage.Text = message;
			return;
		}

		Teacher teacher = dal.ReadTeacher(PAConfiguration.ConnectionString, Teacher.USER_NAME, uname.Value, out message);

		SetCurrentTeacher(teacher);

		Response.Redirect("alerts.aspx");
	}
}
